<template>
    <div class="basic-search fullContent mtb10 mlr10">
        <Layout :total="totalCount" @setHeight="setTableHeight" @handleSizeChange="handleSizeChange"
            @handleCurrentChange="handleCurrentChange" ref="layout" showHightSearch="noKeyword">
            <template slot="btnSort">
                <el-button type="primary" @click="doExport()" title="导出">导出</el-button>

                <el-button type="primary" @click="controls()" title="下发调整命令">下发调整命令</el-button>
            </template>
            <template slot="expandSearch">
                <FormGenerate ref="form" @searchResult="searchResult" @reset="resetResult"
                    :renderFormRule="renderFormRule" :span="6" :searchGroup="true" :lableWidth="150" />
            </template>
            <template slot="mainContent">
                <el-table :data="tableData" style="width: 100%;" tooltip-effect="dark" :height="tableHeight"
                    :header-cell-style="tableHeaderCellStyle" @selection-change="handleSelectionChange">
                    <af-table-column fixed type="selection" width="55">
                    </af-table-column>

                    <af-table-column fixed prop="orderNo" label="工单号" align="center"></af-table-column>
                    <af-table-column prop="cityName" label="地市" align="center"></af-table-column>
                    <af-table-column prop="county" label="区县" align="center"></af-table-column>
                    <af-table-column prop="sitName" label="站址名称" align="center"></af-table-column>
                    <af-table-column prop="sitCode" label="站址编码" align="center"></af-table-column>
                    <af-table-column prop="enbId" label="基站ID" align="center"></af-table-column>
                    <af-table-column prop="cellId" label="小区ID" align="center"></af-table-column>
                    <af-table-column prop="cellName" label="小区名称" align="center"></af-table-column>
                    <af-table-column prop="electricalTitl" label="电子倾角调整值" align="center"></af-table-column>
                    <af-table-column prop="powerPa" label="LTE功率PA调整值" align="center"></af-table-column>
                    <af-table-column prop="powerPb" label="LTE功率PB调整值" align="center"></af-table-column>
                    <af-table-column prop="powerMax" label="5G最大发射功率" align="center"></af-table-column>
                    <af-table-column prop="updateTime" label="数据时间" align="center"></af-table-column>
                    <af-table-column prop="remark" label="操作结果" align="center"></af-table-column>
                </el-table>
            </template>
        </Layout>
    </div>
</template>

<script>
    import Layout from 'oss-common/components/Layout'
    import FormGenerate from 'oss-common/components/FormGenerate'
    import Data from '@/common/data.js';
    import {
        getUrl,
        getGUrl,
        exportFile,

    } from '@/api/data.js';
    export default {
        components: {
            Layout,
            FormGenerate
        },
        data() {
            return {
                dialogVisible: false,
                // 所有的字典值
                multipleSelection: [],
                // 表格的高度
                tableHeight: '400',
                // 保存查询条件
                tableData: [],
                searchParam: {
                    pageNo: 1,
                    pageSize: 20,
                    needTotal: true
                },
                renderFormRule: {
                    // 单选下拉
                    city: {
                        label: '地市',
                        value: null,
                        type: 'select',
                        filterable: true,
                        placeholder: this.$t('choosePlaceholder'),
                      option:this.$store.state.cityarr,
                      labelName: 'regionName',
                      valueKey: 'regionName'
                    },

                    sitName: {
                        label: '站址名称',
                        value: null,
                        type: 'input'
                    },
                    sitCode: {
                        label: '站址编码',
                        value: null,
                        type: 'input'
                    },
                    enbId: {
                        label: '基站ID',
                        value: null,
                        type: 'input'
                    },
                    cellId: {
                        label: '小区ID',
                        value: null,
                        type: 'input'
                    },
                    cellName: {
                        label: '小区名称',
                        value: null,
                        type: 'input'
                    }
                },

                type: 'add'
            }
        },
        methods: {
            controls() {
                if (!this.multipleSelection.length) return this.$message("请选择需要下发的列表");
                let arrStr = this.multipleSelection.map(item => item.keyId).join();


                getUrl("/api/public/ccellChangesetControls.do", {
                        "keyId": arrStr
                    })
                    .then((query) => {
                        if (query.success) {
                            this.tableData = query.listMap
                            this.totalCount = query.total
                        } else {
                            this.$message.error('查询失败！')
                        }
                    })
                    .catch((error) => {

                    })



            },
            handleSelectionChange(val) {
                this.multipleSelection = val;
            },
            tableHeaderCellStyle({
                row,
                column,
                rowIndex,
                columnIndex
            }) {
                let cellStyle1
                cellStyle1 = 'height:40px; '
                return cellStyle1
            },

            /**
             * 点击查询，查询列表
             */
            searchResult(obj) {
                // 分页重置为第一页
                // this.layout.currentPage = 1
                // 查询时，关键字清空，分页重置为第一页
                this.searchParam = Object.assign(
                    JSON.parse(JSON.stringify(obj)), {}, {
                        pageNo: 1,
                        pageSize: this.searchParam.pageSize,
                        needTotal: true
                    },


                )
                this.queryList()
            },
            /**
             * 点击重置，查询列表
             */
            resetResult(obj) {
                this.layout.keyWord = null
            },
            /**
             * 调用接口查询数据列表
             */
            queryList() {
                this.searchParam.city=this.$store.state.city=='浙江'?this.$refs.form.ruleForm.city: this.$store.state.city;
                getUrl("/api/public/cellChangeList.do", this.searchParam)
                    .then((query) => {
                        if (query.success) {
                            this.tableData = query.body.listInfo
                            this.totalCount = query.body.totalCount
                        } else {
                            this.$message.error('查询失败！')
                        }
                    })
                    .catch((error) => {

                    })
            },
            /**
             * 调用接口查询数据列表
             */

            doExport() {
                // 传参数
                this.searchParam.exportType = 5;
                this.searchParam.city=this.$store.state.city=='浙江'?this.$refs.form.ruleForm.city: this.$store.state.city;
                exportFile("/api/export/onExportData?evtStr="+encodeURIComponent(JSON.stringify(this.searchParam)))
            },
            /**
             * pagesize触发查询
             */
            handleSizeChange(val) {
                this.searchParam.size = val
                this.queryList()
            },
            /**
             * 分页查询
             */
            handleCurrentChange(val) {
                this.searchParam.page = val
                this.queryList()
            },

            // 设置表格高度
            setTableHeight(height) {
                this.tableHeight = height - 40
            }
        },
        mounted() {
            this.queryList()
        }
    }
</script>

<style lang="scss" scoped>
    @import 'oss-common/theme/const-theme.scss';
</style>
